<?php if(!defined('HDPHP_PATH'))exit;C('SHOW_NOTICE',FALSE);?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <title>添加商品</title>
<link rel="stylesheet" type="text/css" href="http://localhost/0423/suning/Application/Admin/View/Public/css/admin_style.css" />
<link rel="stylesheet" type="text/css" href="http://localhost/0423/suning/Application/Admin/View/Public/css/table.css" />
<script type="text/javascript">
var APP = "http://localhost/0423/suning";	
</script>
<script src="http://localhost/0423/suning/Static/js/jquery-1.7.2.min.js"></script>
	<script src="http://localhost/0423/suning/Application/Admin/View/Public/js/addController.js"></script>
    <script type="text/javascript" src="http://localhost/0423/suning/Static/uploadify/jquery.uploadify.min.js"></script>
    <link href="http://localhost/0423/suning/Static/uploadify/uploadify.css" type="text/css" rel="stylesheet"></link>
       <!-- 配置文件 -->
    <script type="text/javascript" src="http://localhost/0423/suning/Static/ueditor/ueditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="http://localhost/0423/suning/Static/ueditor/ueditor.all.min.js"></script>
    <script type="text/javascript">
    $(function(){
        $('select[name=pid]').change(function(){
           tid = $(':selected').attr('tid');
            $.ajax({
               type: "POST",
               url: "<?php echo U('getGoodsAttr');?>",
               data: {tid:tid},
               dataType:'json',
               success: function(msg){
                    var attr = '';
                    var spec = '';
                    $.each(msg,function(k,v){
                        //==0属性 ==1 规格
                        if(v.attr_class == 0){
                            attr += "<li style='width:200px; heigh:50px;line-heigt:50px;inline-block;padding:5px 5px;'><input type='hidden' name='type_tid' value='"+v.type_tid+"' />"+v.attr_name+": <select name='attr[]' class='w200'><option value=''>选择属性</option>";
                                $.each(v.attrValue,function(kk,vv){
                                     attr += " <option value='"+v.aid+"|"+vv+"'>"+vv+"</option>";
                                });                       
                            attr += " </select></li>";
                        }else{
                           spec += "<li>"+v.attr_name+":<br/> ";
                                $.each(v.attrValue,function(kk,vv){
                                    spec += " <span class='attrtitle' style='width:180px;display:inline-block; heigh:50px;line-heigt:50px;'><input type='checkbox' value='"+v.aid+"|"+vv+"' name='spec[]'  />"+vv+"</span><span style='width:100px; heigh:50px;line-heigt:50px;inline-block;'>附加价格:<input type='text' name='specPric[]' class='w100'  /></span><br/>";
                                }); 
                                spec += " </li>";
                        }
                        
                    })
                    $('.attrValue').html(attr);
                    $('.specValue').html(spec);
               }
            });
        })
        //附加价格  规格
        $('.specValue input').live('click',function(event) {
                  s=$(this).index();
            if($('.specValue input').eq(s).attr('checked') == true){    
                alert(s);
                   $('.specValue span').eq(s).html('<input type="text" name="goods_attr_value[]" class="w100"/>');
            }else if($(this).attr('checked') == false){
               
            }
        })
        

    })
    </script>
</head>
<body>
<body class="right_body">
	<div class="body">
		<div class="top_subnav">CMS内容管理平台 ＞ 添加商品</div>


		<div style="clear:both"></div>
		<div class="use_meth">
			<div class="title">
				<div class="title_info light">
					添加商品
				</div>
			</div>
<div class="wrap">
    <div class="hd-title-header">添加商品</div>
    <form action="" method="post" class="form-inline hd-form" enctype="multipart/form-data">
        <table class="hd-table hd-table-list">
           	
            <tr>
                <th class="w100">所属分类</th>
                <td>
                    <select name="pid" class="w200">
                        <option value="">选择分类</option>
                       <?php foreach ($cateInfo as $k=>$v){?>
                            <option value="<?php echo $v['cid'];?>" tid ="<?php echo $v['type_tid'];?>"><?php echo $v['_name'];?></option>
                        <?php }?>
                    </select>
                </td>
                <td></td>
            </tr>
            <tr>
                <th class="w100">所属品牌</th>
                <td>
                    <select name="bid" class="w200">
                        <option value="">选择品牌</option>
                       <?php foreach ($brandInfo as $k=>$v){?>
                            <option value="<?php echo $v['bid'];?>"><?php echo $v['brand_name'];?></option>
                        <?php }?>
                    </select>
                </td>
             <td></td>
            </tr>
            <tr>
                <th class="w100">商品名称</th>
                <td  class="w100">
                    <input type="text" name="goods_name" class="w200"/> 
                </td>
                <td>商品名称长度 1 到 100 位</td>
            </tr>
            <tr>
                <th class="w100">商品副标题</th>
                <td  class="w100">
                    <input type="text" name="goods_hot_title" class="w200"/> 
                </td>
                <td>商品热门推荐文字</td>
            </tr>
            <tr>
                <th class="w100">商品数量</th>
                <td>
                    <input type="text" name="goods_inventory" class="w200"/>
                </td>
                <td>  </td>
            </tr>
            <tr>
                <th class="w100">市场价格</th>
                <td>
                    <input type="text" name="goods_market" class="w200"/>
                </td>
                <td></td>
            </tr>
            <tr>
                <th class="w100">商城价格</th>
                <td>
                  <input type="text" name="goods_mall" class="w200"/>
                </td>
                <td></td>
            </tr>
            <tr>
                <th class="w100">单位</th>
                <td>
                    <select name="goods_unit" class="w200">
                        <option value="">选择单位</option>
                      
                            <option value="个">个</option>
                            <option value="件">件</option>
                            <option value="件">条</option>
                            <option value="件">支</option>
                    </select>
                </td>
             <td></td>
            </tr>
           <tr>
                <th class="w100">商品属性</th>
                <td>
                 <div class="attrValue" width="650">
                  

                </div>
                </td>
             <td></td>
            </tr>
          
           

           <tr>
            
           
                <th class="w100">商品规格</th>
                <td>
                    <div class="specValue" width="650">
                        

                    </div>
                </td>
                <td></td>
            </tr>
           <tr>
            
           
                <th class="w100">上传图像</th>
                <td class="uploadChoose">
					<input type="button" class="formUpload btn" value="表单上传" /><input type="button" class="ajaxUpload btn" value="无刷新上传" />
                </td>
                <td></td>
            </tr>
           
            <tr class="tab1">
                <th class="w100">表单上传</th>
                <td class='showGoosIMg' width="650">
                  <input type="file" name="goodsImg[]" />  
                </td>
                <td><span class="addInputFile btn">添加上传</span><span class="delInputFile btn">删除上传</span></td>
            </tr>
            
           
            <tr class="tab1">
                <th class="w100">无刷新上传</th>
                <td>
                  <div lab="uploadFile">
                <input id="listIMg" type="file" name="" multiple="true">
                <span>类型: *.jpg 大小: 2000KB 数量: 5</span>
                <script type="text/javascript">
                    $(function() {
                        $('#listIMg').uploadify({
                            'formData'     : {//POST数据
                                '<?php echo session_name();?>' : '<?php echo session_id();?>',
                            },
                            'fileTypeDesc' : '上传文件',//上传描述
                            'fileTypeExts' : '*.jpg',
                            'swf'      : 'http://localhost/0423/suning/Static/uploadify/uploadify.swf',
                            'uploader' : '<?php echo U("Admin/goods/uploadGoodsImg");?>',
                            'buttonText':'选择文件',
                            'fileSizeLimit' : '2000KB',
                            'uploadLimit' : 1000,//上传文件数
                            'width':65,
                            // 'debug':true,
                            'height':25,
                            'successTimeout':10,//等待服务器响应时间
                            'removeTimeout' : 0.2,//成功显示时间
                            'onUploadSuccess' : function(file, data, response) {
                                data=$.parseJSON(data);
                                var imageUrl = data.image?data.url:'http://localhost/0423/suning/Static/image/default.png';
                                var li="<li path='"+data.path+"' url='"+data.url+"'><img src='"+imageUrl+"' class='hd-w80 hd-h70' /><div class='hiddenli'><span class='look'>查看</span><span class='del' >删除</span><span class='imgshow'><img /><span class='close'></span></span></div></li>";
                                $(".showGoosListIMg").prepend(li);
                                $('#inputHidden').append('<li>'+data.goods_info_smallIMg+'</li>');
                                //获取图片域值
                               var smallIMg =  $('#goods_info_smallIMg').val();
                                   $('#goods_info_smallIMg').val(smallIMg+','+data.goods_info_smallIMg);
                            }
                        });
                    });
                </script>
                </td>
                <td>
                	<!--异步隐藏内容-->
                	<div id='inputHidden' style="display:none;">
                		
                	</div>
                </td>
            </tr>
            
            <tr>
                <th class="w100">列表图预览</th>
                <td class='showGoosListIMg' width="650">
                  
                </td>
                <td></td>
            </tr>
            <tr>
                <th class="w100">商品详情</th>
                <td>
                   <!-- 加载编辑器的容器 -->
    <script id="container" name="goods_info_detail" type="text/plain" style="width: 650px; z-index: 999;">
       
    </script>

    <!-- 实例化编辑器 -->
    <script type="text/javascript">
        var ue = UE.getEditor('container');
    </script>
                </td>
                <td>分类描述长度 1 到 255位  </td>
            </tr>
            <input id="goods_info_smallIMg" type="hidden" name="goods_info_smallIMg" value="" />
            <tr>
                <th class="w100">包装及参数</th>
                <td>
                   <!-- 加载编辑器的容器 -->
    <script id="container_sever" name="goods_info_sever" type="text/plain" style="width: 650px; z-index: 999;">
      
    </script>

    <!-- 实例化编辑器 -->
    <script type="text/javascript">
        var ue = UE.getEditor('container_sever');
    </script>
                </td>
                <td>分类描述长度 1 到 255位  </td>
            </tr>
            
        </table>
        <div class="position-bottom">
            <input type="submit" class="hd-btn hd-btn-success" value="添加"/>
        </div>
    </form>
</div>
		</div>
	
	</div>




</body>
</html>
